function x_est = mmse_vblast_detector(y, H, SNR)
    % MMSE-VBLAST检测器实现
    % 输入:
    % y - 接收信号向量 (Nr x 1)
    % H - 信道矩阵 (Nr x Nt)
    % SNR - 信噪比(dB)
    % 输出:
    % x_est - 估计的发送信号向量 (Nt x 1)
    
    % 获取系统大小
    [Nr, Nt] = size(H);
    
    % 初始化
    x_est = zeros(Nt, 1);
    H_temp = H;
    y_temp = y;
    detect_order = zeros(Nt, 1);
    noise_var = 10^(-SNR/10);
    
    % MMSE-VBLAST逐层检测
    for i = 1:Nt
        % 构造扩展矩阵
        H_ext = [H_temp; sqrt(noise_var)*eye(size(H_temp, 2))];
        y_ext = [y_temp; zeros(size(H_temp, 2), 1)];
        
        % 计算MMSE权重矩阵
        W = H_temp' * inv(H_temp*H_temp' + noise_var*eye(size(H_temp, 1)));
        
        % 计算后验SNR并选择最佳检测顺序
        post_snr = zeros(size(H_temp, 2), 1);
        for j = 1:size(H_temp, 2)
            post_snr(j) = abs(W(j,:)*H_temp(:,j))^2 / (noise_var*sum(abs(W(j,:)).^2));
        end
        [~, max_idx] = max(post_snr);
        detect_order(i) = max_idx;
        
        % 检测符号
        x_est(detect_order(i)) = W(max_idx, :) * y_temp;
        
        % 硬判决
        x_est(detect_order(i)) = sign(real(x_est(detect_order(i)))) + ...
                                1j*sign(imag(x_est(detect_order(i))));
        
        % 消除已检测层的干扰
        y_temp = y_temp - H_temp(:, max_idx) * x_est(detect_order(i));
        H_temp(:, max_idx) = [];
    end
end 